home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / XAMPP 1.4.14 / xampp-win32-1.4.14-installer.exe / xampp / mysql / scripts / make_binary_distribution < prev    next >
Text File  |  2005-04-01  |  10KB  |  383 lines

  1. #!/bin/sh
  2. # The default path should be /usr/local
  3.  
  4. # Get some info from configure
  5. # chmod +x ./scripts/setsomevars
  6.  
  7. machine=i686
  8. system=pc-linux-gnu
  9. version=4.1.11
  10. export machine system version
  11. SOURCE=`pwd` 
  12. CP="cp -p"
  13. MV="mv"
  14.  
  15. STRIP=1
  16. DEBUG=0
  17. SILENT=0
  18. TMP=/tmp
  19. SUFFIX=""
  20. NDBCLUSTER=
  21.  
  22. parse_arguments() {
  23.   for arg do
  24.     case "$arg" in
  25.       --debug)    DEBUG=1;;
  26.       --tmp=*)    TMP=`echo "$arg" | sed -e "s;--tmp=;;"` ;;
  27.       --suffix=*) SUFFIX=`echo "$arg" | sed -e "s;--suffix=;;"` ;;
  28.       --no-strip) STRIP=0 ;;
  29.       --silent)   SILENT=1 ;;
  30.       --with-ndbcluster) NDBCLUSTER=1 ;;
  31.       *)
  32.     echo "Unknown argument '$arg'"
  33.     exit 1
  34.         ;;
  35.     esac
  36.   done
  37. }
  38.  
  39. parse_arguments "$@"
  40.  
  41. #make
  42.  
  43. # This should really be integrated with automake and not duplicate the
  44. # installation list.
  45.  
  46. BASE=$TMP/my_dist$SUFFIX
  47.  
  48. if [ -d $BASE ] ; then
  49.  rm -r -f $BASE
  50. fi
  51.  
  52. BS=""
  53. BIN_FILES=""
  54. BASE_SYSTEM="any"
  55. MYSQL_SHARE=$BASE/share/mysql
  56.  
  57. case $system in
  58.   *netware*)
  59.     BASE_SYSTEM="netware"
  60.     BS=".nlm"
  61.     MYSQL_SHARE=$BASE/share
  62.     ;;
  63. esac
  64.  
  65.  
  66. mkdir $BASE $BASE/bin $BASE/docs \
  67.  $BASE/include $BASE/lib $BASE/support-files $BASE/share $BASE/scripts \
  68.  $BASE/mysql-test $BASE/mysql-test/t  $BASE/mysql-test/r \
  69.  $BASE/mysql-test/include $BASE/mysql-test/std_data $BASE/mysql-test/lib
  70.  
  71. if [ $BASE_SYSTEM != "netware" ] ; then
  72.  mkdir $BASE/share/mysql $BASE/tests $BASE/sql-bench $BASE/man \
  73.   $BASE/man/man1 $BASE/data $BASE/data/mysql $BASE/data/test
  74.  
  75.  chmod o-rwx $BASE/data $BASE/data/*
  76. fi
  77.  
  78. for i in ChangeLog \
  79.          Docs/manual.html \
  80.          Docs/manual.txt \
  81.          Docs/manual_toc.html \
  82.                  Docs/mysql.info
  83. do
  84.   if [ -f $i ]
  85.   then
  86.     $CP $i $BASE/docs
  87.   fi
  88. done
  89.  
  90. for i in COPYING COPYING.LIB README Docs/INSTALL-BINARY \
  91.          EXCEPTIONS-CLIENT MySQLEULA.txt LICENSE.doc README.NW
  92. do
  93.   if [ -f $i ]
  94.   then
  95.     $CP $i $BASE
  96.   fi
  97. done
  98.  
  99. # Non platform-specific bin dir files:
  100. BIN_FILES="extra/comp_err$BS extra/replace$BS extra/perror$BS \
  101.   extra/resolveip$BS extra/my_print_defaults$BS \
  102.   extra/resolve_stack_dump$BS extra/mysql_waitpid$BS \
  103.   isam/isamchk$BS isam/pack_isam$BS \
  104.   myisam/myisamchk$BS myisam/myisampack$BS myisam/myisamlog$BS \
  105.   myisam/myisam_ftdump$BS \
  106.   sql/mysqld$BS sql/mysql_tzinfo_to_sql$BS \
  107.   client/mysql$BS client/mysqlshow$BS client/mysqladmin$BS \
  108.   client/mysqldump$BS client/mysqlimport$BS \
  109.   client/mysqltest$BS client/mysqlcheck$BS \
  110.   client/mysqlbinlog$BS \
  111.   tests/mysql_client_test$BS \
  112.   libmysqld/examples/mysql_client_test_embedded$BS \
  113.   libmysqld/examples/mysqltest_embedded$BS \
  114.   ";
  115.  
  116. # Platform-specific bin dir files:
  117. if [ $BASE_SYSTEM = "netware" ] ; then
  118.   BIN_FILES="$BIN_FILES \
  119.     netware/mysqld_safe$BS netware/mysql_install_db$BS \
  120.     netware/init_db.sql netware/test_db.sql netware/mysql_explain_log$BS \
  121.     netware/mysqlhotcopy$BS netware/libmysql$BS netware/init_secure_db.sql
  122.     ";
  123. else
  124.   # For all other platforms:
  125.   BIN_FILES="$BIN_FILES \
  126.     client/mysqlmanagerc \
  127.     client/mysqlmanager-pwgen tools/mysqlmanager \
  128.     client/.libs/mysql client/.libs/mysqlshow client/.libs/mysqladmin \
  129.     client/.libs/mysqldump client/.libs/mysqlimport \
  130.     client/.libs/mysqltest client/.libs/mysqlcheck \
  131.     client/.libs/mysqlbinlog client/.libs/mysqlmanagerc \
  132.     client/.libs/mysqlmanager-pwgen tools/.libs/mysqlmanager \
  133.     tests/.libs/mysql_client_test \
  134.     libmysqld/examples/.libs/mysql_client_test_embedded \
  135.     libmysqld/examples/.libs/mysqltest_embedded \
  136.   ";
  137. fi
  138.  
  139. for i in $BIN_FILES
  140. do
  141.   if [ -f $i ]
  142.   then
  143.     $CP $i $BASE/bin
  144.   fi
  145. done
  146.  
  147. if [ x$STRIP = x1 ] ; then
  148.   strip $BASE/bin/*
  149. fi
  150.  
  151. # Copy not binary files
  152. for i in sql/mysqld.sym.gz
  153. do
  154.   if [ -f $i ]
  155.   then
  156.     $CP $i $BASE/bin
  157.   fi
  158. done
  159.  
  160. if [ $BASE_SYSTEM = "netware" ] ; then
  161.     $CP -r netware/*.pl $BASE/scripts
  162.     $CP scripts/mysqlhotcopy $BASE/scripts/mysqlhotcopy.pl
  163. fi
  164.  
  165. for i in \
  166.   libmysql/.libs/libmysqlclient.a libmysql/.libs/libmysqlclient.so* \
  167.   libmysql/libmysqlclient.* libmysql_r/.libs/libmysqlclient_r.a \
  168.   libmysql_r/.libs/libmysqlclient_r.so* libmysql_r/libmysqlclient_r.* \
  169.   mysys/libmysys.a strings/libmystrings.a dbug/libdbug.a \
  170.   libmysqld/.libs/libmysqld.a libmysqld/.libs/libmysqld.so* \
  171.   libmysqld/libmysqld.a netware/libmysql.imp
  172. do
  173.   if [ -f $i ]
  174.   then
  175.     $CP $i $BASE/lib
  176.    fi
  177. done
  178.  
  179. # convert the .a to .lib for NetWare
  180. if [ $BASE_SYSTEM = "netware" ] ; then
  181.     for i in $BASE/lib/*.a
  182.     do
  183.       libname=`basename $i .a`
  184.       $MV $i $BASE/lib/$libname.lib
  185.     done
  186. fi
  187.  
  188. $CP config.h include/* $BASE/include
  189. rm -f $BASE/include/Makefile* $BASE/include/*.in $BASE/include/config-win.h
  190. if [ $BASE_SYSTEM != "netware" ] ; then
  191.   rm -f $BASE/include/config-netware.h
  192. fi
  193.  
  194. if [ $BASE_SYSTEM != "netware" ] ; then
  195.   if [ -d tests ] ; then
  196.     $CP tests/*.res tests/*.tst tests/*.pl $BASE/tests
  197.   fi
  198.   if [ -d man ] ; then
  199.     $CP man/*.1 $BASE/man/man1
  200.   fi
  201. fi
  202.  
  203. $CP support-files/* $BASE/support-files
  204. $CP scripts/*.sql $BASE/share
  205.  
  206. $CP -r sql/share/* $MYSQL_SHARE
  207. rm -f $MYSQL_SHARE/Makefile* $MYSQL_SHARE/*/*.OLD
  208.  
  209. for i in mysql-test/mysql-test-run mysql-test/install_test_db \
  210.          mysql-test/mysql-test-run.pl mysql-test/README \
  211.          netware/mysql_test_run.nlm netware/install_test_db.ncf
  212. do
  213.   if [ -f $i ]
  214.   then
  215.     $CP $i $BASE/mysql-test
  216.    fi
  217. done
  218.  
  219. $CP mysql-test/lib/*.pl  $BASE/mysql-test/lib
  220. $CP mysql-test/lib/*.sql $BASE/mysql-test/lib
  221. $CP mysql-test/include/*.inc $BASE/mysql-test/include
  222. $CP mysql-test/std_data/*.dat mysql-test/std_data/*.*001 $BASE/mysql-test/std_data
  223. $CP mysql-test/std_data/des_key_file $BASE/mysql-test/std_data
  224. $CP mysql-test/t/*test mysql-test/t/*.opt mysql-test/t/*.slave-mi mysql-test/t/*.sh $BASE/mysql-test/t
  225. $CP mysql-test/r/*result mysql-test/r/*result.es mysql-test/r/*.require $BASE/mysql-test/r
  226.  
  227. if [ $BASE_SYSTEM != "netware" ] ; then
  228.   chmod a+x $BASE/bin/*
  229.   $CP scripts/* $BASE/bin
  230.   $BASE/bin/replace \@localstatedir\@ ./data \@bindir\@ ./bin \@scriptdir\@ ./bin \@libexecdir\@ ./bin \@sbindir\@ ./bin \@prefix\@ . \@HOSTNAME\@ /bin/hostname \@pkgdatadir\@ ./support-files < $SOURCE/scripts/mysql_install_db.sh > $BASE/scripts/mysql_install_db
  231.   $BASE/bin/replace \@prefix\@ /usr/local/mysql \@bindir\@ ./bin \@MYSQLD_USER\@ root \@localstatedir\@ /usr/local/mysql/data \@HOSTNAME\@ /bin/hostname < $SOURCE/support-files/mysql.server.sh > $BASE/support-files/mysql.server
  232.   $BASE/bin/replace /my/gnu/bin/hostname /bin/hostname -- $BASE/bin/mysqld_safe
  233.   mv $BASE/support-files/binary-configure $BASE/configure
  234.   chmod a+x $BASE/bin/* $BASE/scripts/* $BASE/support-files/mysql-* $BASE/support-files/mysql.server $BASE/configure
  235.   $CP -r sql-bench/* $BASE/sql-bench
  236.   rm -f $BASE/sql-bench/*.sh $BASE/sql-bench/Makefile* $BASE/lib/*.la
  237.   rm -f $BASE/bin/*.sql
  238. fi
  239.  
  240. rm -f $BASE/bin/Makefile* $BASE/bin/*.in $BASE/bin/*.sh $BASE/bin/mysql_install_db $BASE/bin/make_binary_distribution $BASE/bin/setsomevars $BASE/support-files/Makefile* $BASE/support-files/*.sh
  241.  
  242.  
  243. #
  244. # Copy system dependent files
  245. #
  246. if [ $BASE_SYSTEM = "netware" ] ; then
  247.   echo "CREATE DATABASE mysql;" > $BASE/bin/init_db.sql
  248.   echo "CREATE DATABASE test;" >> $BASE/bin/init_db.sql
  249.   sh ./scripts/mysql_create_system_tables.sh real "" "%" 0 >> $BASE/bin/init_db.sql
  250.   sh ./scripts/mysql_create_system_tables.sh test "" "%" 0 > $BASE/bin/test_db.sql
  251. #  cp ./netware/static_init_db.sql ./netware/init_db.sql
  252. #  ./scripts/fill_help_tables < ./Docs/manual.texi >> ./netware/init_db.sql
  253. fi
  254.  
  255. #
  256. # Remove system dependent files
  257. #
  258. if [ $BASE_SYSTEM = "netware" ] ; then
  259.   rm -f $BASE/support-files/magic \
  260.         $BASE/support-files/mysql.server \
  261.         $BASE/support-files/mysql*.spec \
  262.         $BASE/support-files/mysql-log-rotate \
  263.         $BASE/support-files/binary-configure \
  264.         $BASE/INSTALL-BINARY \
  265.         $BASE/MySQLEULA.txt
  266. else
  267.     rm -f $BASE/README.NW
  268. fi
  269.  
  270. # Make safe_mysqld a symlink to mysqld_safe for backwards portability
  271. # To be removed in MySQL 4.1
  272. (cd $BASE/bin ; ln -s mysqld_safe safe_mysqld )
  273.  
  274. # Clean up if we did this from a bk tree
  275. if [ -d $BASE/sql-bench/SCCS ] ; then 
  276.   find $BASE/share -name SCCS -print | xargs rm -r -f
  277.   find $BASE/sql-bench -name SCCS -print | xargs rm -r -f
  278. fi
  279.  
  280. # NDB Cluster
  281. if [ x$NDBCLUSTER = x1 ]; then
  282.   ( cd ndb            ; make DESTDIR=$BASE/ndb-stage install )
  283.   ( cd mysql-test/ndb ; make DESTDIR=$BASE/ndb-stage install )
  284.   $CP $BASE/ndb-stage/usr/local/bin/* $BASE/bin/.
  285.   $CP $BASE/ndb-stage/usr/local/libexec/* $BASE/bin/.
  286.   $CP $BASE/ndb-stage/usr/local/lib/mysql/* $BASE/lib/.
  287.   $CP -r $BASE/ndb-stage/usr/local/include/mysql/ndb $BASE/include
  288.   $CP -r $BASE/ndb-stage/usr/local/mysql-test/ndb $BASE/mysql-test/. || exit 1
  289.   rm -rf $BASE/ndb-stage
  290. fi
  291.  
  292. # Change the distribution to a long descriptive name
  293. NEW_NAME=mysql-$version-$system-$machine$SUFFIX
  294. BASE2=$TMP/$NEW_NAME
  295. rm -r -f $BASE2
  296. mv $BASE $BASE2
  297. BASE=$BASE2
  298. #
  299. # If we are compiling with gcc, copy libgcc.a to the distribution as libmygcc.a
  300. #
  301.  
  302. if test "yes" = "yes"
  303. then
  304.   cd $BASE/lib
  305.   gcclib=`ccache gcc --print-libgcc-file`
  306.   if test $? -ne 0
  307.   then
  308.     print "Warning: Couldn't find libgcc.a!"
  309.   else
  310.     $CP $gcclib libmygcc.a
  311.   fi
  312.   cd $SOURCE
  313. fi
  314.  
  315. #if we are debugging, do not do tar/gz
  316. if [ x$DEBUG = x1 ] ; then
  317.  exit
  318. fi
  319.  
  320. # This is needed to prefere gnu tar instead of tar because tar can't
  321. # always handle long filenames
  322.  
  323. PATH_DIRS=`echo $PATH | sed -e 's/^:/. /' -e 's/:$/ ./' -e 's/::/ . /g' -e 's/:/ /g' `
  324. which_1 ()
  325. {
  326.   for cmd
  327.   do
  328.     for d in $PATH_DIRS
  329.     do
  330.       for file in $d/$cmd
  331.       do
  332.     if test -x $file -a ! -d $file
  333.     then
  334.       echo $file
  335.       exit 0
  336.     fi
  337.       done
  338.     done
  339.   done
  340.   exit 1
  341. }
  342.  
  343. if [ $BASE_SYSTEM != "netware" ] ; then
  344.  
  345.   #
  346.   # Create the result tar file
  347.   #
  348.   
  349.   tar=`which_1 gnutar gtar`
  350.   if test "$?" = "1" -o "$tar" = ""
  351.   then
  352.     tar=tar
  353.   fi
  354.   
  355.   echo "Using $tar to create archive"
  356.   cd $TMP
  357.   
  358.   OPT=cvf
  359.   if [ x$SILENT = x1 ] ; then
  360.     OPT=cf
  361.   fi
  362.   
  363.   $tar $OPT $SOURCE/$NEW_NAME.tar $NEW_NAME
  364.   cd $SOURCE
  365.   echo "Compressing archive"
  366.   rm -f $NEW_NAME.tar.gz
  367.   gzip -9 $NEW_NAME.tar
  368.   echo "$NEW_NAME.tar.gz created"
  369. else
  370.  
  371.   #
  372.   # Create a zip file for NetWare users
  373.   #
  374.  
  375.   cd $TMP
  376.   if test -e "$SOURCE/$NEW_NAME.zip"; then rm $SOURCE/$NEW_NAME.zip; fi
  377.   zip -r $SOURCE/$NEW_NAME.zip $NEW_NAME
  378.   echo "$NEW_NAME.zip created"
  379.  
  380. fi
  381. echo "Removing temporary directory"
  382. rm -r -f $BASE
  383.